package api.homework.two.teacherHW;

/**
 * @author lwj
 * @date 2025-03-12
 * @vesion 1.0.0
 */
public class MyRunnable implements Runnable{
    /**
     * 电影票
     */
    private int ticket = 50;

    @Override
    public synchronized void run() {
        while(true){
            if(ticket < 0){
                break;
            }

            String name = Thread.currentThread().getName();
            System.out.println(name+"出售了第" + ticket-- +"张票");
        }
    }
}
